package com.hsc.yalebao.tools;

import android.annotation.SuppressLint;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.Toast;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.weight.LogUtils;
import com.hsc.yalebao.weight.RoundImageView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.DisplayImageOptions.Builder;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageSize;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import com.zhy.http.okhttp.callback.BitmapCallback;
import java.text.DecimalFormat;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import okhttp3.Call;

@SuppressLint({"NewApi"})
public class UiUtil
{
  private static String TAG = "UiUtil";
  public static ImageSize mImageSize = new ImageSize(400, 200);
  public static DisplayImageOptions options = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).resetViewBeforeLoading(true).showImageOnFail(0).bitmapConfig(Bitmap.Config.RGB_565).build();
  private static Toast toast;

  public static boolean IsValueEmpty(String paramString)
  {
    return (paramString == null) || (paramString.trim().length() <= 0) || (paramString.toLowerCase().equals("null"));
  }

  public static String StringFilter(String paramString)
  {
    if (paramString != null)
    {
      String str = paramString.replace(" ", "");
      return Pattern.compile("[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]").matcher(str).replaceAll("").trim().toLowerCase();
    }
    return "";
  }

  private static Bitmap alphaLayer(Bitmap paramBitmap, Context paramContext, int paramInt)
  {
    int i = paramBitmap.getWidth();
    int j = paramBitmap.getHeight();
    Bitmap localBitmap1 = Bitmap.createBitmap(i, j, Bitmap.Config.RGB_565);
    Bitmap localBitmap2 = BitmapFactory.decodeResource(paramContext.getResources(), paramInt);
    int k = localBitmap2.getWidth();
    int m = localBitmap2.getHeight();
    float f1 = 1.0F * i / k;
    float f2 = 1.0F * j / m;
    Matrix localMatrix = new Matrix();
    localMatrix.postScale(f1, f2);
    Bitmap localBitmap3 = Bitmap.createBitmap(localBitmap2, 0, 0, k, m, localMatrix, true);
    int i1;
    for (int n = 0; ; n++)
    {
      if (n >= i)
        return localBitmap1;
      i1 = 0;
      if (i1 < j)
        break;
    }
    int i2 = paramBitmap.getPixel(n, i1);
    int i3 = localBitmap3.getPixel(n, i1);
    int i4 = Color.red(i2);
    int i5 = Color.green(i2);
    int i6 = Color.blue(i2);
    int i7 = Color.alpha(i2);
    int i8 = Color.red(i3);
    int i9 = Color.green(i3);
    int i10 = Color.blue(i3);
    int i11 = Color.alpha(i3);
    if ((i8 < 20) && (i9 < 20) && (i10 < 20));
    for (float f3 = 1.0F; ; f3 = 0.3F)
    {
      float f4 = f3;
      float f5 = f3;
      float f6 = f3;
      int i12 = (int)(f4 * i4 + i8 * (1.0F - f4));
      int i13 = (int)(f5 * i5 + i9 * (1.0F - f5));
      int i14 = (int)(f6 * i6 + i10 * (1.0F - f6));
      int i15 = (int)(f3 * i7 + i11 * (1.0F - f3));
      int i16 = Math.min(255, Math.max(0, i12));
      int i17 = Math.min(255, Math.max(0, i13));
      int i18 = Math.min(255, Math.max(0, i14));
      int i19 = Color.argb(Math.min(255, Math.max(0, i15)), i16, i17, i18);
      localBitmap1.setPixel(n, i1, i19);
      i1++;
      break;
    }
  }

  public static boolean checkEmail(String paramString)
  {
    return Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$").matcher(paramString).matches();
  }

  public static boolean checkPhone(String paramString)
  {
    return Pattern.compile("(^[0-9]{3,4}[0-9]{7,8}$)|(^[0-9]{3,4}-[0-9]{7,8}$)|^(13[0-9]|14[5|7]|15[0-9]|18[0-9])\\d{8}$").matcher(paramString).matches();
  }

  public static boolean checkTelephone(String paramString)
  {
    return Pattern.compile("[0-9]{11}").matcher(paramString).matches();
  }

  public static void copy(String paramString, Context paramContext)
  {
    ((ClipboardManager)paramContext.getSystemService("clipboard")).setText(paramString.trim());
  }

  public static int dip2px(Context paramContext, float paramFloat)
  {
    return (int)(0.5F + paramFloat * paramContext.getResources().getDisplayMetrics().density);
  }

  public static Bitmap getBitMap(Context paramContext, int paramInt)
  {
    Bitmap localBitmap = BitmapFactory.decodeResource(paramContext.getResources(), paramInt);
    int i = localBitmap.getHeight();
    int j = localBitmap.getWidth();
    LogUtils.d("getBitMap", "width:" + j);
    LogUtils.d("getBitMap", "height:" + i);
    return localBitmap;
  }

  private static Context getContext()
  {
    return CustomApplication.getIntance();
  }

  public static Bitmap getCroppedRoundBitmap(Bitmap paramBitmap, int paramInt)
  {
    int i = paramInt * 2;
    int j = paramBitmap.getWidth();
    int k = paramBitmap.getHeight();
    Bitmap localBitmap1;
    if (k > j)
    {
      localBitmap1 = Bitmap.createBitmap(paramBitmap, 0, (k - j) / 2, j, j);
      if ((localBitmap1.getWidth() == i) && (localBitmap1.getHeight() == i))
        break label245;
    }
    label245: for (Bitmap localBitmap2 = Bitmap.createScaledBitmap(localBitmap1, i, i, true); ; localBitmap2 = localBitmap1)
    {
      Bitmap localBitmap3 = Bitmap.createBitmap(localBitmap2.getWidth(), localBitmap2.getHeight(), Bitmap.Config.ARGB_8888);
      Canvas localCanvas = new Canvas(localBitmap3);
      Paint localPaint = new Paint();
      Rect localRect = new Rect(0, 0, localBitmap2.getWidth(), localBitmap2.getHeight());
      localPaint.setAntiAlias(true);
      localPaint.setFilterBitmap(true);
      localPaint.setDither(true);
      localCanvas.drawARGB(0, 0, 0, 0);
      localCanvas.drawCircle(localBitmap2.getWidth() / 2, localBitmap2.getHeight() / 2, localBitmap2.getWidth() / 2, localPaint);
      localPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
      localCanvas.drawBitmap(localBitmap2, localRect, localRect, localPaint);
      return localBitmap3;
      if (k < j)
      {
        localBitmap1 = Bitmap.createBitmap(paramBitmap, (j - k) / 2, 0, k, k);
        break;
      }
      localBitmap1 = paramBitmap;
      break;
    }
  }

  public static String[] getListFormString(String paramString)
  {
    if (paramString == null)
      return null;
    if (paramString.endsWith(";"))
    {
      paramString = paramString.substring(0, -1 + paramString.length());
      LogUtils.d(TAG, "str:" + paramString);
    }
    return paramString.split(";");
  }

  public static BitmapFactory.Options getOptions(Context paramContext, int paramInt)
  {
    BitmapFactory.Options localOptions = new BitmapFactory.Options();
    localOptions.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(paramContext.getResources(), paramInt, localOptions);
    localOptions.inSampleSize = 1;
    localOptions.inJustDecodeBounds = false;
    BitmapFactory.decodeResource(paramContext.getResources(), paramInt, localOptions);
    int i = localOptions.outWidth;
    int j = localOptions.outHeight;
    LogUtils.d("getOptions", "width:" + i);
    LogUtils.d("getOptions", "height:" + j);
    return localOptions;
  }

  public static boolean isAllChinese(String paramString)
  {
    if (!TextUtils.isEmpty(paramString))
      return paramString.matches("[一-龥]+");
    return false;
  }

  public static boolean isApplationInstalled(Context paramContext, String paramString)
  {
    List localList = paramContext.getPackageManager().getInstalledPackages(0);
    if (localList != null);
    for (int i = 0; ; i++)
    {
      if (i >= localList.size())
        return false;
      String str = ((PackageInfo)localList.get(i)).packageName;
      LogUtils.i(TAG, "packageNameStr:" + str);
      if (str.equals(paramString))
        return true;
    }
  }

  public static boolean isContainsChinese(String paramString)
  {
    boolean bool1 = Pattern.compile("[一-龥]").matcher(paramString).find();
    boolean bool2 = false;
    if (bool1)
      bool2 = true;
    return bool2;
  }

  public static boolean isEmail(String paramString)
  {
    return Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$").matcher(paramString).matches();
  }

  public static boolean isEmpty(CharSequence paramCharSequence)
  {
    return (paramCharSequence == null) || (paramCharSequence.toString().trim().length() == 0) || ("null".equals(paramCharSequence.toString().trim()));
  }

  public static boolean isMobileNO(String paramString)
  {
    return Pattern.compile("^((1[34578][0-9]{1}))\\d{8}$").matcher(paramString).matches();
  }

  public static boolean isValidEmail(String paramString)
  {
    return paramString.matches("[a-zA-Z0-9_\\.]{1,}@(([a-zA-z0-9]-*){1,}\\.){1,3}[a-zA-z\\-]{1,}");
  }

  public static boolean isValidMobiNumber(String paramString)
  {
    return paramString.matches("^1\\d{10}$");
  }

  public static boolean isValidName(String paramString)
  {
    return paramString.matches("[a-zA-Z0-9_]{1,}");
  }

  public static boolean isValidUserName(String paramString)
  {
    if (paramString.matches("^[a-z0-9A-Z]{6,12}$"))
    {
      LogUtils.e("isValidUserName", "true");
      return true;
    }
    LogUtils.e("isValidUserName", "false");
    return false;
  }

  public static void loadAndSetPhoto(RoundImageView paramRoundImageView, String paramString)
  {
    String str = AppConstants.BASE_URL_IMG + paramString;
    LogUtils.e(TAG, "imgUrl:" + str);
    ImageLoader.getInstance().loadImage(str, mImageSize, options, new SimpleImageLoadingListener()
    {
      public void onLoadingComplete(String paramAnonymousString, View paramAnonymousView, Bitmap paramAnonymousBitmap)
      {
        if (paramAnonymousBitmap != null)
          UiUtil.this.setImageBitmap(paramAnonymousBitmap);
        while (true)
        {
          super.onLoadingComplete(paramAnonymousString, paramAnonymousView, paramAnonymousBitmap);
          return;
          LogUtils.e(UiUtil.TAG, "loadedImage==null");
        }
      }
    });
  }

  public static void loadAndSetPhoto2(RoundImageView paramRoundImageView, String paramString)
  {
    String str = AppConstants.BASE_URL_IMG + paramString;
    LogUtils.e(TAG, "imgUrl:" + str);
    ImageLoader.getInstance().loadImage(str, mImageSize, options, new SimpleImageLoadingListener()
    {
      public void onLoadingComplete(String paramAnonymousString, View paramAnonymousView, Bitmap paramAnonymousBitmap)
      {
        if (paramAnonymousBitmap != null)
          UiUtil.this.setImageBitmap(paramAnonymousBitmap);
        while (true)
        {
          super.onLoadingComplete(paramAnonymousString, paramAnonymousView, paramAnonymousBitmap);
          return;
          LogUtils.e(UiUtil.TAG, "loadedImage==null");
        }
      }

      public void onLoadingStarted(String paramAnonymousString, View paramAnonymousView)
      {
        super.onLoadingStarted(paramAnonymousString, paramAnonymousView);
        UiUtil.this.setImageResource(2130838020);
      }
    });
  }

  public static void loadImage(String paramString, Context paramContext, ImageView paramImageView)
  {
    LogUtils.d(TAG, "imgUrl:" + paramString);
    RequestNet.bindImageToView(paramString, paramContext, new BitmapCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        LogUtils.e(UiUtil.TAG, "loadImage-访问失败");
      }

      public void onResponse(Bitmap paramAnonymousBitmap)
      {
        LogUtils.d(UiUtil.TAG, "下载图像成功");
        if (paramAnonymousBitmap != null)
        {
          UiUtil.this.setImageBitmap(paramAnonymousBitmap);
          return;
        }
        LogUtils.e(UiUtil.TAG, "图像bitmap==null");
      }
    });
  }

  public static void loadRoundImage(String paramString, Context paramContext, RoundImageView paramRoundImageView)
  {
    LogUtils.d(TAG, "imgUrl:" + paramString);
    RequestNet.bindImageToView(paramString, paramContext, new BitmapCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        LogUtils.e(UiUtil.TAG, "loadImage-访问失败");
      }

      public void onResponse(Bitmap paramAnonymousBitmap)
      {
        LogUtils.d(UiUtil.TAG, "下载图像成功");
        if (paramAnonymousBitmap != null)
        {
          UiUtil.this.setImageBitmap(paramAnonymousBitmap);
          return;
        }
        LogUtils.e(UiUtil.TAG, "图像bitmap==null");
      }
    });
  }

  public static Bitmap montageBitmap(Bitmap paramBitmap1, Bitmap paramBitmap2, int paramInt1, int paramInt2)
  {
    int i = paramBitmap2.getWidth();
    int j = paramBitmap2.getHeight();
    Bitmap localBitmap1 = Bitmap.createScaledBitmap(paramBitmap1, i, j, true);
    Bitmap localBitmap2 = Bitmap.createBitmap(i, j, Bitmap.Config.ARGB_8888);
    Canvas localCanvas = new Canvas(localBitmap2);
    localCanvas.drawBitmap(paramBitmap2, paramInt1, paramInt2, null);
    localCanvas.drawBitmap(localBitmap1, 0.0F, 0.0F, null);
    return localBitmap2;
  }

  public static String numToString(int paramInt)
  {
    switch (paramInt)
    {
    default:
      return "";
    case 0:
      return "零";
    case 1:
      return "一";
    case 2:
      return "二";
    case 3:
      return "三";
    case 4:
      return "四";
    case 5:
      return "五";
    case 6:
      return "六";
    case 7:
      return "七";
    case 8:
      return "八";
    case 9:
      return "九";
    case 10:
    }
    return "十";
  }

  public static String paste(Context paramContext)
  {
    return ((ClipboardManager)paramContext.getSystemService("clipboard")).getText().toString().trim();
  }

  public static int px2dip(Context paramContext, float paramFloat)
  {
    return (int)(0.5F + paramFloat / paramContext.getResources().getDisplayMetrics().density);
  }

  public static int px2sp(Context paramContext, float paramFloat)
  {
    return (int)(0.5F + paramFloat / paramContext.getResources().getDisplayMetrics().scaledDensity);
  }

  public static String savePoint(double paramDouble, int paramInt)
  {
    if (paramInt <= 0)
      return paramDouble;
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; ; i++)
    {
      if (i >= paramInt)
        return new DecimalFormat("######0." + localStringBuffer.toString()).format(paramDouble);
      localStringBuffer.append("0");
    }
  }

  public static void shake(Context paramContext, View paramView)
  {
    paramView.startAnimation(AnimationUtils.loadAnimation(paramContext, 2130968609));
  }

  public static void showToast(Context paramContext, String paramString)
  {
    if (toast == null);
    for (toast = Toast.makeText(paramContext, paramString, 0); ; toast = Toast.makeText(paramContext, paramString, 0))
    {
      toast.show();
      return;
      toast.cancel();
    }
  }

  public static void showToast(String paramString)
  {
    showToast(getContext(), paramString);
  }

  public static int sp2px(Context paramContext, float paramFloat)
  {
    return (int)(0.5F + paramFloat * paramContext.getResources().getDisplayMetrics().scaledDensity);
  }

  public static Bitmap toRoundCorner(Bitmap paramBitmap, int paramInt)
  {
    Bitmap localBitmap = Bitmap.createBitmap(paramBitmap.getWidth(), paramBitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas localCanvas = new Canvas(localBitmap);
    Paint localPaint = new Paint();
    Rect localRect = new Rect(0, 0, paramBitmap.getWidth(), paramBitmap.getHeight());
    RectF localRectF = new RectF(localRect);
    float f = paramInt * paramBitmap.getWidth() / 160;
    localPaint.setAntiAlias(true);
    localCanvas.drawARGB(0, 0, 0, 0);
    localPaint.setColor(-12434878);
    localCanvas.drawRoundRect(localRectF, f, f, localPaint);
    localPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    localCanvas.drawBitmap(paramBitmap, localRect, localRect, localPaint);
    return localBitmap;
  }

  public static Bitmap transparentImage(Bitmap paramBitmap)
  {
    Bitmap localBitmap = Bitmap.createBitmap(paramBitmap.getWidth(), paramBitmap.getHeight(), paramBitmap.getConfig());
    int i = localBitmap.getWidth();
    int j = localBitmap.getHeight();
    int m;
    for (int k = 0; ; k++)
    {
      if (k >= j)
        return localBitmap;
      m = 0;
      if (m < i)
        break;
    }
    int n = paramBitmap.getPixel(m, k);
    if (n == 0);
    while (true)
    {
      m++;
      break;
      int i1 = Color.red(n);
      int i2 = Color.green(n);
      int i3 = Color.blue(n);
      int i4 = Color.alpha(n);
      int i5 = (Math.max(i3, Math.max(i1, i2)) + Math.min(i3, Math.min(i1, i2))) / 2;
      localBitmap.setPixel(m, k, Color.argb(i4, i5, i5, i5));
    }
  }

  public static abstract interface OnSetTitleListener
  {
    public abstract void onClick(View paramView);
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.tools.UiUtil
 * JD-Core Version:    0.6.2
 */